//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "PiecewiseYieldCurveDiscountLogLinear.h"
using namespace Cephei::QL::Termstructures::Yield;
#include <gen/QL/Times/Calendar.h>
#include <gen/QL/Termstructures/Yield/RateHelper.h>
#include <gen/QL/Times/DayCounter.h>
#include <gen/QL/Quote.h>
#include <gen/QL/InterestRate.h>
#include <gen/QL/Times/Period.h>
#include <gen/QL/Termstructures/YieldTermStructure.h>
using namespace Cephei::QL::Times;
using namespace Cephei::QL;
using namespace Cephei::QL::Termstructures;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
    CCalendar^ _Ccalendar;
    CDayCounter^ _CdayCounter;
    try
    {
#ifdef HANDLE
        _phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
        QuantLib::Natural _settlementDays = (QuantLib::Natural)ValueHelper::Convert (settlementDays); //d
        _Ccalendar = safe_cast<CCalendar^> (calendar);
        _Ccalendar->Lock();
        QuantLib::Calendar& _calendar = static_cast<QuantLib::Calendar&> (_Ccalendar->GetReference ()); 
        instruments ->Lock ();
        INativeVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ _NCIinstruments = instruments->getFeature (NativeFeature::shared_ptr);
        CRateHelperVector^ _NCinstruments = safe_cast<CRateHelperVector^>(_NCIinstruments);
        std::vector<boost::shared_ptr<QuantLib::RateHelper> >& _instruments = static_cast<std::vector<boost::shared_ptr<QuantLib::RateHelper> >&> (_NCinstruments->GetShared ());
        _CdayCounter = safe_cast<CDayCounter^> (dayCounter);
        _CdayCounter->Lock();
        QuantLib::DayCounter& _dayCounter = static_cast<QuantLib::DayCounter&> (_CdayCounter->GetReference ()); 
        _ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (new QuantLib::PiecewiseYieldCurveDiscountLogLinear ( _settlementDays,  _calendar,  _instruments,  _dayCounter ));
        SetYieldTermStructure (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Ccalendar != nullptr) _Ccalendar->Unlock();
        if (instruments != nullptr) instruments->Unlock();    //not optional
        if (_CdayCounter != nullptr) _CdayCounter->Unlock();
    }
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Double accuracy) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
    CCalendar^ _Ccalendar;
    CDayCounter^ _CdayCounter;
    try
    {
#ifdef HANDLE
        _phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
        QuantLib::Natural _settlementDays = (QuantLib::Natural)ValueHelper::Convert (settlementDays); //d
        _Ccalendar = safe_cast<CCalendar^> (calendar);
        _Ccalendar->Lock();
        QuantLib::Calendar& _calendar = static_cast<QuantLib::Calendar&> (_Ccalendar->GetReference ()); 
        instruments ->Lock ();
        INativeVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ _NCIinstruments = instruments->getFeature (NativeFeature::shared_ptr);
        CRateHelperVector^ _NCinstruments = safe_cast<CRateHelperVector^>(_NCIinstruments);
        std::vector<boost::shared_ptr<QuantLib::RateHelper> >& _instruments = static_cast<std::vector<boost::shared_ptr<QuantLib::RateHelper> >&> (_NCinstruments->GetShared ());
        _CdayCounter = safe_cast<CDayCounter^> (dayCounter);
        _CdayCounter->Lock();
        QuantLib::DayCounter& _dayCounter = static_cast<QuantLib::DayCounter&> (_CdayCounter->GetReference ()); 
        QuantLib::Real _accuracy = (QuantLib::Real)ValueHelper::Convert (accuracy); //d
        _ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (new QuantLib::PiecewiseYieldCurveDiscountLogLinear ( _settlementDays,  _calendar,  _instruments,  _dayCounter,  _accuracy ));
        SetYieldTermStructure (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Ccalendar != nullptr) _Ccalendar->Unlock();
        if (instruments != nullptr) instruments->Unlock();    //not optional
        if (_CdayCounter != nullptr) _CdayCounter->Unlock();
    }
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>^ jumps, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>^ jumpDates, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
    CCalendar^ _Ccalendar;
    CDayCounter^ _CdayCounter;
    try
    {
#ifdef HANDLE
        _phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
        QuantLib::Natural _settlementDays = (QuantLib::Natural)ValueHelper::Convert (settlementDays); //d
        _Ccalendar = safe_cast<CCalendar^> (calendar);
        _Ccalendar->Lock();
        QuantLib::Calendar& _calendar = static_cast<QuantLib::Calendar&> (_Ccalendar->GetReference ()); 
        instruments ->Lock ();
        INativeVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ _NCIinstruments = instruments->getFeature (NativeFeature::shared_ptr);
        CRateHelperVector^ _NCinstruments = safe_cast<CRateHelperVector^>(_NCIinstruments);
        std::vector<boost::shared_ptr<QuantLib::RateHelper> >& _instruments = static_cast<std::vector<boost::shared_ptr<QuantLib::RateHelper> >&> (_NCinstruments->GetShared ());
        _CdayCounter = safe_cast<CDayCounter^> (dayCounter);
        _CdayCounter->Lock();
        QuantLib::DayCounter& _dayCounter = static_cast<QuantLib::DayCounter&> (_CdayCounter->GetReference ()); 
        CQuoteVector^ _NCjumps;
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>::IsSome::get (jumps))
        {
            jumps->Value->Lock();
            INativeVector<Cephei::QL::IQuote^>^ _NCIjumps = jumps->Value->getFeature (NativeFeature::Handle);
            _NCjumps = safe_cast<CQuoteVector^>(_NCIjumps);
        }
        std::vector<Handle<QuantLib::Quote> >& _jumps = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>::IsSome::get (jumps) ? static_cast<std::vector<Handle<QuantLib::Quote> >&> (_NCjumps->GetHandle ()) : std::vector<Handle<QuantLib::Quote> >());//2
        CDateTimeVector^ _NCjumpDates;
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>::IsSome::get (jumpDates))
        {
            jumpDates->Value->Lock();
            INativeVector<DateTime>^ _NCIjumpDates = jumpDates->Value->getFeature (NativeFeature::Value);
            _NCjumpDates = safe_cast<CDateTimeVector^>(_NCIjumpDates);
        }
        std::vector<QuantLib::Date>& _jumpDates = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>::IsSome::get (jumpDates) ? static_cast<std::vector<QuantLib::Date>&> (_NCjumpDates->GetReference ()) : std::vector<QuantLib::Date>()); //3
        QuantLib::Real _accuracy = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (accuracy) ? (QuantLib::Real)ValueHelper::Convert (accuracy->Value) : 1.0e-12); //4
        _ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (new QuantLib::PiecewiseYieldCurveDiscountLogLinear ( _settlementDays,  _calendar,  _instruments,  _dayCounter,  _jumps,  _jumpDates,  _accuracy ));
        SetYieldTermStructure (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Ccalendar != nullptr) _Ccalendar->Unlock();
        if (instruments != nullptr) instruments->Unlock();    //not optional
        if (_CdayCounter != nullptr) _CdayCounter->Unlock();
        if (jumps != nullptr) jumps->Value->Unlock();
        if (jumpDates != nullptr) jumpDates->Value->Unlock();
    }
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (DateTime referenceDate, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Double accuracy) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
    CDayCounter^ _CdayCounter;
    try
    {
#ifdef HANDLE
        _phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
        QuantLib::Date _referenceDate = (QuantLib::Date)ValueHelper::Convert (referenceDate); //d
        instruments ->Lock ();
        INativeVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ _NCIinstruments = instruments->getFeature (NativeFeature::shared_ptr);
        CRateHelperVector^ _NCinstruments = safe_cast<CRateHelperVector^>(_NCIinstruments);
        std::vector<boost::shared_ptr<QuantLib::RateHelper> >& _instruments = static_cast<std::vector<boost::shared_ptr<QuantLib::RateHelper> >&> (_NCinstruments->GetShared ());
        _CdayCounter = safe_cast<CDayCounter^> (dayCounter);
        _CdayCounter->Lock();
        QuantLib::DayCounter& _dayCounter = static_cast<QuantLib::DayCounter&> (_CdayCounter->GetReference ()); 
        QuantLib::Real _accuracy = (QuantLib::Real)ValueHelper::Convert (accuracy); //d
        _ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (new QuantLib::PiecewiseYieldCurveDiscountLogLinear ( _referenceDate,  _instruments,  _dayCounter,  _accuracy ));
        SetYieldTermStructure (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (instruments != nullptr) instruments->Unlock();    //not optional
        if (_CdayCounter != nullptr) _CdayCounter->Unlock();
    }
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (DateTime referenceDate, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>^ jumps, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>^ jumpDates, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
    CDayCounter^ _CdayCounter;
    try
    {
#ifdef HANDLE
        _phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
        QuantLib::Date _referenceDate = (QuantLib::Date)ValueHelper::Convert (referenceDate); //d
        instruments ->Lock ();
        INativeVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ _NCIinstruments = instruments->getFeature (NativeFeature::shared_ptr);
        CRateHelperVector^ _NCinstruments = safe_cast<CRateHelperVector^>(_NCIinstruments);
        std::vector<boost::shared_ptr<QuantLib::RateHelper> >& _instruments = static_cast<std::vector<boost::shared_ptr<QuantLib::RateHelper> >&> (_NCinstruments->GetShared ());
        _CdayCounter = safe_cast<CDayCounter^> (dayCounter);
        _CdayCounter->Lock();
        QuantLib::DayCounter& _dayCounter = static_cast<QuantLib::DayCounter&> (_CdayCounter->GetReference ()); 
        CQuoteVector^ _NCjumps;
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>::IsSome::get (jumps))
        {
            jumps->Value->Lock();
            INativeVector<Cephei::QL::IQuote^>^ _NCIjumps = jumps->Value->getFeature (NativeFeature::Handle);
            _NCjumps = safe_cast<CQuoteVector^>(_NCIjumps);
        }
        std::vector<Handle<QuantLib::Quote> >& _jumps = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>::IsSome::get (jumps) ? static_cast<std::vector<Handle<QuantLib::Quote> >&> (_NCjumps->GetHandle ()) : std::vector<Handle<QuantLib::Quote> >());//2
        CDateTimeVector^ _NCjumpDates;
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>::IsSome::get (jumpDates))
        {
            jumpDates->Value->Lock();
            INativeVector<DateTime>^ _NCIjumpDates = jumpDates->Value->getFeature (NativeFeature::Value);
            _NCjumpDates = safe_cast<CDateTimeVector^>(_NCIjumpDates);
        }
        std::vector<QuantLib::Date>& _jumpDates = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>::IsSome::get (jumpDates) ? static_cast<std::vector<QuantLib::Date>&> (_NCjumpDates->GetReference ()) : std::vector<QuantLib::Date>()); //3
        QuantLib::Real _accuracy = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (accuracy) ? (QuantLib::Real)ValueHelper::Convert (accuracy->Value) : 1.0e-12); //4
        _ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (new QuantLib::PiecewiseYieldCurveDiscountLogLinear ( _referenceDate,  _instruments,  _dayCounter,  _jumps,  _jumpDates,  _accuracy ));
        SetYieldTermStructure (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (instruments != nullptr) instruments->Unlock();    //not optional
        if (_CdayCounter != nullptr) _CdayCounter->Unlock();
        if (jumps != nullptr) jumps->Value->Unlock();
        if (jumpDates != nullptr) jumpDates->Value->Unlock();
    }
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear>& childNative, Object^ owner) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
#ifdef HANDLE
	_phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
	_ppPiecewiseYieldCurveDiscountLogLinear = &childNative;
    _ppYieldTermStructure = new boost::shared_ptr<QuantLib::YieldTermStructure> (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (QuantLib::PiecewiseYieldCurveDiscountLogLinear& childNative, Object^ owner) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
#ifdef HANDLE
	_phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
	_ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (&childNative);
    _ppYieldTermStructure = new boost::shared_ptr<QuantLib::YieldTermStructure> (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
    _PiecewiseYieldCurveDiscountLogLinearOwner = owner;
    _YieldTermStructureOwner = owner;
}

Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (CPiecewiseYieldCurveDiscountLogLinear^ copy) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
#ifdef HANDLE
	_phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (copy->GetShared());
        _ppYieldTermStructure = new boost::shared_ptr<QuantLib::YieldTermStructure> (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
    }
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (PLATFORM::Type^ t) : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
#ifdef HANDLE
	_phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
	if (!t->IsSubclassOf(CPiecewiseYieldCurveDiscountLogLinear::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (QuantLib::Handle<QuantLib::PiecewiseYieldCurveDiscountLogLinear>& childNative, Object^ owner)  : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
	_phPiecewiseYieldCurveDiscountLogLinear = &childNative;
	_ppPiecewiseYieldCurveDiscountLogLinear = &static_cast<boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear>>(childNative.currentLink());
    _ppYieldTermStructure = new boost::shared_ptr<QuantLib::YieldTermStructure> (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
    _PiecewiseYieldCurveDiscountLogLinearOwner = owner;
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (QuantLib::Handle<QuantLib::PiecewiseYieldCurveDiscountLogLinear> childNative)  : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
	_phPiecewiseYieldCurveDiscountLogLinear = &childNative;
	_ppPiecewiseYieldCurveDiscountLogLinear = &static_cast<boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear>>(childNative.currentLink());
    _ppYieldTermStructure = new boost::shared_ptr<QuantLib::YieldTermStructure> (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
}
#endif
#ifdef STRUCT
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::CPiecewiseYieldCurveDiscountLogLinear (QuantLib::PiecewiseYieldCurveDiscountLogLinear childNative)  : CYieldTermStructure(CPiecewiseYieldCurveDiscountLogLinear::typeid)
{
#ifdef HANDLE
	_phPiecewiseYieldCurveDiscountLogLinear = NULL;
#endif
	_ppPiecewiseYieldCurveDiscountLogLinear = new boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (new QuantLib::PiecewiseYieldCurveDiscountLogLinear (childNative));
    _ppYieldTermStructure = new boost::shared_ptr<QuantLib::YieldTermStructure> (boost::dynamic_pointer_cast<QuantLib::YieldTermStructure> (*_ppPiecewiseYieldCurveDiscountLogLinear));
}
#endif

Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::~CPiecewiseYieldCurveDiscountLogLinear ()
{
    if (_ppPiecewiseYieldCurveDiscountLogLinear != NULL)
    {
	    delete _ppPiecewiseYieldCurveDiscountLogLinear;
        _ppPiecewiseYieldCurveDiscountLogLinear = NULL;
    }
}
Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::!CPiecewiseYieldCurveDiscountLogLinear ()
{
    if (_ppPiecewiseYieldCurveDiscountLogLinear != NULL)
    {
	    delete _ppPiecewiseYieldCurveDiscountLogLinear;
    }
}
QuantLib::PiecewiseYieldCurveDiscountLogLinear& Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::GetReference ()
{
    if (_ppPiecewiseYieldCurveDiscountLogLinear == NULL) throw REFNEW NativeNullException ();
	return **_ppPiecewiseYieldCurveDiscountLogLinear;
}
boost::shared_ptr<QuantLib::PiecewiseYieldCurveDiscountLogLinear>& Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::GetShared ()
{
    if (_ppPiecewiseYieldCurveDiscountLogLinear == NULL) throw REFNEW NativeNullException ();
	return *_ppPiecewiseYieldCurveDiscountLogLinear;
}
QuantLib::PiecewiseYieldCurveDiscountLogLinear* Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::GetPointer ()
{
    if (_ppPiecewiseYieldCurveDiscountLogLinear == NULL) throw REFNEW NativeNullException ();
	return &**_ppPiecewiseYieldCurveDiscountLogLinear;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::PiecewiseYieldCurveDiscountLogLinear>& Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::GetHandle ()
{
	if (_phPiecewiseYieldCurveDiscountLogLinear == NULL)
	{
		_phPiecewiseYieldCurveDiscountLogLinear = new Handle<QuantLib::PiecewiseYieldCurveDiscountLogLinear> (*_ppPiecewiseYieldCurveDiscountLogLinear);
	}
	return *_phPiecewiseYieldCurveDiscountLogLinear;
}
#endif
bool Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear::HasNative () 
{
	return (_ppPiecewiseYieldCurveDiscountLogLinear != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Termstructures::Yield::IPiecewiseYieldCurveDiscountLogLinear^ Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear_Factory::Create (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter)
{
    return REFNEW CPiecewiseYieldCurveDiscountLogLinear ( settlementDays,  calendar,  instruments,  dayCounter);
}
Cephei::QL::Termstructures::Yield::IPiecewiseYieldCurveDiscountLogLinear^ Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear_Factory::Create (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Double accuracy)
{
    return REFNEW CPiecewiseYieldCurveDiscountLogLinear ( settlementDays,  calendar,  instruments,  dayCounter,  accuracy);
}
Cephei::QL::Termstructures::Yield::IPiecewiseYieldCurveDiscountLogLinear^ Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear_Factory::Create (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>^ jumps, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>^ jumpDates, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy)
{
    return REFNEW CPiecewiseYieldCurveDiscountLogLinear ( settlementDays,  calendar,  instruments,  dayCounter,  jumps,  jumpDates,  accuracy);
}
Cephei::QL::Termstructures::Yield::IPiecewiseYieldCurveDiscountLogLinear^ Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear_Factory::Create (DateTime referenceDate, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Double accuracy)
{
    return REFNEW CPiecewiseYieldCurveDiscountLogLinear ( referenceDate,  instruments,  dayCounter,  accuracy);
}
Cephei::QL::Termstructures::Yield::IPiecewiseYieldCurveDiscountLogLinear^ Cephei::QL::Termstructures::Yield::CPiecewiseYieldCurveDiscountLogLinear_Factory::Create (DateTime referenceDate, Cephei::Core::IVector<Cephei::QL::Termstructures::Yield::IRateHelper^>^ instruments, Cephei::QL::Times::IDayCounter^ dayCounter, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<Cephei::QL::IQuote^>^>^ jumps, Microsoft::FSharp::Core::FSharpOption<Cephei::Core::IVector<DateTime>^>^ jumpDates, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy)
{
    return REFNEW CPiecewiseYieldCurveDiscountLogLinear ( referenceDate,  instruments,  dayCounter,  jumps,  jumpDates,  accuracy);
}
